﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Configuration;

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        ResWindow resWin;
        private void button1_Click(object sender, EventArgs e)
        {
            int evId = -1;
            int raceId = -1;
            IDbConnection conn = new MySql.Data.MySqlClient.MySqlConnection(ConfigurationManager.AppSettings["OLACONN"]);
            conn.Open();
            try{
                Lofas.OlaParser.Event[] events = Lofas.OlaParser.GetEvents(conn);
                FrmEventSelector frm = new FrmEventSelector(events);
                if (frm.ShowDialog(this) == DialogResult.OK)
                {
                    evId = frm.EventID;
                    raceId = frm.RaceID;
                }
                else
                {
                    return;
                }
            }
            catch (Exception ee)
            {
                    MessageBox.Show(this,"Error connecting to DB: " + ee.Message);
            }
            finally
            {
                conn.Close();
            }

            resWin = new ResWindow(evId,raceId);   
            resWin.Show();
            resWin.FormBorderStyle = FormBorderStyle.Sizable;
            if (checkBox1.Checked)
            {
                resWin.WindowState = FormWindowState.Maximized;
                resWin.FormBorderStyle = FormBorderStyle.None;
            }
            
            

        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (!checkBox1.Checked)
            {
                resWin.WindowState = FormWindowState.Normal;
                resWin.FormBorderStyle = FormBorderStyle.Sizable;
            }
            else
            {
                resWin.FormBorderStyle = FormBorderStyle.None;
                resWin.WindowState = FormWindowState.Maximized;
            }
        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            resWin.HighContrast = checkBox2.Checked;
        }
    }
}